#include<iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    char star[7],goup[7];
    int a=1,b=1;
    gets(star);
    gets(goup);

    for (int i = 0; star[i] ; i++) 
    a*=star[i]-'@';
    
    for (int i = 0; goup[i] ; i++
    ) b*= goup[i]-'@';
    
    if(a%47 == b%47) puts("GO");
    else puts("STAY");
    return 0;
}
